package com.xiaozhu.utils;

/**
 * @author 朱慧军
 * @version 1.0
 */


public class BaseContext {

    /**
     * ThreadLocal 是线程局部变量，每个线程都有自己的副本，互不干扰。
     * 此处用于保存当前线程的用户ID。
     */
    private static ThreadLocal<Long> threadLocal = new ThreadLocal<>();

    public static Long getThreadId() {
        return threadLocal.get();
    }

    public static void setThreadId(Long threadId) {
        threadLocal.set(threadId);
    }

    public static void removeThreadId() {
        threadLocal.remove();
    }
}
